<template>
    <div>

    </div>
</template>

<script>
    export default {
        name: "Base",
        data(){
            return {
                tableData: [],
                total:0,
                loading:true,
                dataFilter:{current:1,size:10},
                editModal:false,
                viewModal:false
            }
        },
        methods:{
            changeSize(size){
                this.dataFilter.size=size;
                if(this.dataFilter.current==1){
                    this.changePage(this.dataFilter.current);
                }
            },
            changePage(current){
                this.dataFilter.current=current;
                this.loadData();
            },baseLoadData(url,callback){
                this.loading=true;
                this.editModal=false
                this.$axios.post(url,this.$qs.stringify(this.dataFilter)).then(res=>{
                    let code = res.data.code;
                    let data = res.data.data;
                    if(code==200){
                        this.tableData=data.records;
                        this.total=data.total;
                        this.loading=false;
                        this.dataFilter.current=data.current;
                        this.dataFilter.size=data.size;
                        if(callback!=null){
                            callback();
                        }
                    }else{
                        this.$Message.error(data.msg);
                    }
                }).catch(()=>{
                    this.$Message.error('服务器未响应!');
                });
            },baseRemove(url,data){
                this.$Modal.confirm({
                    title: '提示！',
                    content: '确认删除?',
                    onOk: () => {
                        this.loading=true;
                        this.$axios.post(url,this.$qs.stringify(data)).then(res=>{
                            let code = res.data.code;
                            let data = res.data.data;
                            if(code==200){
                                this.loading=false;
                                this.loadData();
                            }else{
                                this.$Message.error(data.msg);
                            }
                        }).catch(()=>{
                            this.$Message.error('服务器未响应!');
                        });
                    }
                });
            }
        }
    }
</script>

<style scoped>

</style>
